package com.example.viewex;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MyListAdapter extends ArrayAdapter {

	private Context context;
	private int layout;
	private LayoutInflater inflater;
	

	String[] title = {"어그레시브", "USD", "Razors", "Rollerblade"};
	String[] contents = {"111", "222", "333", "444"};
	int imgs[] = {R.drawable.dd1, R.drawable.dd3, R.drawable.jd01, R.drawable.usd22};
	
	
	public MyListAdapter(Context context, int resource) {
		super(context, resource);
		
		this.context = context;
		this.layout = resource;
		
		inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
	}

	@Override
	public int getCount() {
		
		return title.length;
	}

	@Override
	public Object getItem(int position) {

		return title[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return super.getItemId(position);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		// position 위치번호
		
		
		View view = inflater.inflate(layout, null);
		
		
		ImageView iv = (ImageView)view.findViewById(R.id.imageView1);
		TextView tv1 = (TextView)view.findViewById(R.id.textView1);
		TextView tv2 = (TextView)view.findViewById(R.id.textView2);
		
		iv.setImageResource(imgs[position]);
		tv1.setText(title[position]);
		tv2.setText(contents[position]);
		
		return view;
	}

	
	
}
